package logic

import (
	"context"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"user_srv/model"
	"user_srv/user_proto"
)

func (s *Server) GetUserByMobile(ctx context.Context, in *user_proto.GetUserByMobileRequest) (*user_proto.GetUserByMobileResponse, error) {
	mobile, err := model.GetUserByMobile(in.Mobile)
	if err != nil {
		return nil, status.Errorf(codes.Internal, "用户查询失败")
	}
	return &user_proto.GetUserByMobileResponse{
		Id:       int64(mobile.ID),
		Mobile:   mobile.Mobile,
		Password: mobile.Password,
	}, nil
}
